import pandas as pd
import numpy as np
np.random.seed(0)
m,n,p = 100,80,50
# 100*50
B = np.random.randint(0,2,(m,p))
# 50*80
U = np.random.randint(0,2,(p,n))
# 100*80
Z = np.random.randint(0,2,(m,n))
def solution(B=B, U=U, Z=Z):
    L_res = []
    for i in range(m):
        for j in range(n):
            norm_value = ((B[i]-U[:,j])**2).sum()
            L_res.append(norm_value*Z[i][j])
    return sum(L_res)
'''
bi 为 b的第i行 uj为u的第j列
b
'''
if __name__ == '__main__':
    a = solution(B,U,Z)
    print(a)
    y1 = (B**2).sum(1)
    print(y1.shape)
    print((B**2).shape)
    R = (((B**2).sum(1).reshape(-1,1) + (U**2).sum(0) - 2*B@U)*Z).sum()

